/*
 * OREKIT-X
 * Copyright 2002-2008 CS Communication & Systemes
 * 
 * Parts of this software package have been licensed to CS
 * Communication & Systemes (CS) under one or more contributor license
 * agreements.  See the NOTICE file distributed with this work for
 * additional information.
 *  
 * This is an experimental copy of OREKIT from www.orekit.org.
 * Please use the original OREKIT from orekit.org for normal work
 * unrelated to this research project.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you
 * may not use this file except in compliance with the License.  You
 * may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.  See the License for the specific language governing
 * permissions and limitations under the License.
 */
package ore.bodies;

import ore.errors.OrekitException;
import ore.time.AbsoluteDate;

/** 
 * Basic representation of JPL ephemerides data.
 * 
 * @author Luc Maisonobe
 * @author John Pritchard
 */
public abstract class JPLEphemerides
    extends JPLConstants
{
    protected static JPLEphemerides Instance;

    public static JPLEphemerides InstanceJPLEphemerides(){
        if (null != JPLEphemerides.Instance)
            return JPLEphemerides.Instance;
        else
            throw OrekitException.createIllegalStateException("data not bound");
    }
    public final static boolean HasJPLEphemerides(){
        return (null != JPLEphemerides.Instance);
    }
    public final static boolean HasNotJPLEphemerides(){
        return (null == JPLEphemerides.Instance);
    }


    public enum EphemerisType {
        MERCURY,
        VENUS,
        EARTH_MOON,
        MARS,
        JUPITER,
        SATURN,
        URANUS,
        NEPTUNE,
        PLUTO,
        MOON,
        SUN;
    }


    protected final EphemerisType type;
    protected final AbsoluteDate centralDate;
    protected AbsoluteDate startEpoch;
    protected AbsoluteDate finalEpoch;

    protected double maxChunksDuration = Double.NaN;
    protected double chunksDuration = Double.NaN;


    /** 
     * @param type ephemeris type to load
     * @param centralDate desired central date
     * (all data within a +/-50 days range around this date will be loaded)
     */
    public JPLEphemerides(EphemerisType type, AbsoluteDate centralDate){
        super();
        this.type          = type;
        this.centralDate   = centralDate;
    }
    protected JPLEphemerides(JPLEphemerides set, EphemerisType type, AbsoluteDate centralDate){
        super((type == set.type)?(set):(null));
        this.type          = type;
        this.centralDate   = centralDate;
    }


    public final EphemerisType getType(){
        return this.type;
    }
    public final AbsoluteDate getCentralDate(){
        return this.centralDate;
    }
    public final AbsoluteDate getStartEpoch(){
        return this.startEpoch;
    }
    public final AbsoluteDate getFinalEpoch(){
        return this.finalEpoch;
    }
    public final double getMaxChunksDuration(){
        return this.maxChunksDuration;
    }
    public final double getChunksDuration(){
        return this.chunksDuration;
    }
}
